//
//  GQProfileHeaderView.m
//  GuQu
//
//  Created by HELIUM STAR on 15/5/9.
//  Copyright (c) 2015年 HELIUM STAR. All rights reserved.
//

#import "GQProfileHeaderView.h"


@implementation GQProfileHeaderView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setUpChildView];
    }
    return self;
}

- (void)setUpChildView
{
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 152 + 64)];
    headerView.backgroundColor = [UIColor whiteColor];
    [self addSubview:headerView];
    
    UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, headerView.width, 100)];
    [headerView addSubview:backView];
    backView.backgroundColor = kNavigationBarColor;
    
    UILabel *title = [[UILabel alloc] init];
    title.width = 120;
    title.height = 20;
    title.x = (backView.width - title.width) / 2;
    title.y = 31;
    title.text = @"林志颖";
    title.font = [UIFont systemFontOfSize:17];
    title.textColor = [UIColor whiteColor];
    title.textAlignment = NSTextAlignmentCenter;
    [backView addSubview:title];
    
    UIButton *rightItem = [[UIButton alloc] init];
    rightItem.width = 22;
    rightItem.height = 22;
    rightItem.x = backView.width - 11 - rightItem.width;
    rightItem.y = 31;
    [rightItem setImage:[UIImage imageNamed:@"setting"] forState:UIControlStateNormal];
    [rightItem addTarget:self action:@selector(settingItemDidClick:) forControlEvents:UIControlEventTouchUpInside];
    [backView addSubview:rightItem];
    
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithRoundName:@"icon"]];
    imageView.width = 60;
    imageView.height = 60;
    imageView.center = CGPointMake(headerView.width / 2, 100);
    [headerView addSubview:imageView];
    
    UIButton *editProInfo = [UIButton buttonWithType:UIButtonTypeCustom];
    editProInfo.width = 100;
    editProInfo.height = 22;
    editProInfo.center = CGPointMake(headerView.width / 2, 85 + kNavigatationBarHeight);
    [editProInfo setTitle:@"编辑个人资料" forState:UIControlStateNormal];
    [editProInfo setTitleColor:[UIColor colorWithRed:93/255.0 green:215/255.0 blue:248/255.0 alpha:1.0] forState:UIControlStateNormal];
    editProInfo.layer.borderColor = [UIColor colorWithRed:93/255.0 green:215/255.0 blue:248/255.0 alpha:1.0].CGColor;
    editProInfo.layer.borderWidth = 1;
    editProInfo.titleLabel.font = [UIFont systemFontOfSize:12];
    [editProInfo addTarget:self action:@selector(editProInfoDidClick:) forControlEvents:UIControlEventTouchUpInside];
    [headerView addSubview:editProInfo];
    
    //关注
    UIView *lineView1 = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(editProInfo.frame) + 10, headerView.width, 0.5)];
    lineView1.backgroundColor = [UIColor lightGrayColor];
    [headerView addSubview:lineView1];
    
    UIView *concernView = [[UIView alloc] init];
    self.concernView = concernView;
    concernView.x = 0;
    concernView.y = CGRectGetMaxY(lineView1.frame);
    concernView.width = headerView.width / 2;
    concernView.height = 45;
    
    
    UILabel *label1 = [[UILabel alloc] init];
    label1.width = 35;
    label1.height = 15;
    label1.x = (concernView.width - label1.width) / 2;
    label1.y = (concernView.height - 15 - 12) / 2;
    label1.text = @"关注";
    label1.font = [UIFont systemFontOfSize:15];
    label1.textAlignment = NSTextAlignmentCenter;
    [concernView addSubview:label1];
    
    UILabel *label1Count = [[UILabel alloc] init];
    label1Count.width = 35;
    label1Count.height = 12;
    label1Count.x = label1.x;
    label1Count.y = CGRectGetMaxY(label1.frame) + 2;
    label1Count.text = @"12";
    label1Count.textColor = [UIColor lightGrayColor];
    label1Count.font = [UIFont systemFontOfSize:10];
    label1Count.textAlignment = NSTextAlignmentCenter;
    [concernView addSubview:label1Count];
    
    [headerView addSubview:concernView];
    
    UIView *lineView2 = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(concernView.frame), concernView.y, 0.5, concernView.height)];
    lineView2.backgroundColor = [UIColor lightGrayColor];
    [headerView addSubview:lineView2];
    
    UIView *fansView = [[UIView alloc] initWithFrame:concernView.frame];
    fansView.x = CGRectGetMaxX(lineView2.frame);
    self.fansView = fansView;
    
    UILabel *label2 = [[UILabel alloc] init];
    label2.width = 35;
    label2.height = 15;
    label2.x = (fansView.width - label2.width) / 2;
    label2.y = label1.y;
    label2.font = [UIFont systemFontOfSize:15];
    label2.text = @"粉丝";
    label2.textAlignment = NSTextAlignmentCenter;
    [fansView addSubview:label2];
    
    UILabel *label2Count = [[UILabel alloc] init];
    label2Count.width = 35;
    label2Count.height = 12;
    label2Count.x = label2.x;
    label2Count.y = label1Count.y;
    label2Count.text = @"8";
    label2Count.textColor = [UIColor lightGrayColor];
    label2Count.font = [UIFont systemFontOfSize:10];
    label2Count.textAlignment = NSTextAlignmentCenter;
    [fansView addSubview:label2Count];
    
    [headerView addSubview:fansView];
    
    
}

- (void)settingItemDidClick:(UIButton *)btn
{
    if ([self.delegate respondsToSelector:@selector(GQProfileHeaderViewSettingDidClick:)]) {
        [self.delegate GQProfileHeaderViewSettingDidClick:btn];
    }
}

- (void)editProInfoDidClick:(UIButton *)btn
{
    if ([self.delegate respondsToSelector:@selector(GQProfileHeaderViewEditDidClick:)]) {
        [self.delegate GQProfileHeaderViewEditDidClick:btn];
    }
    
}

@end
